package com.heima.common.tess4j;

import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

import java.io.File;

public class TessTest {
    public static void main(String[] args) throws TesseractException {
        System.out.println("hello");
        ITesseract iTesseract = new Tesseract();
        //字体库路径 路径里面不要有中文
        iTesseract.setDatapath("D:\\MyApp\\ocr");
        //设置语言
        iTesseract.setLanguage("chi_sim");
        //图片路径
        File file = new File("D:\\MyApp\\ocr\\aa.png");
        String s = iTesseract.doOCR(file);
        System.out.println("图片识别结果："+s.replaceAll("\\r|\\n" , "-"));
    }
}
